from django.shortcuts import render
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import mixins, viewsets

from city.filter import CityFilter
from city.models import China
from city.serializer import CitySerializer


class CityViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
    """
    商品列表页, 分页， 搜索， 过滤， 排序
    """
    # throttle_classes = (UserRateThrottle, )
    queryset = China.objects.all()  # 数据源
    serializer_class = CitySerializer
    filter_backends = (DjangoFilterBackend, )
    filter_class = CityFilter
    # pagination_class = InvolverInfoPagination  # 分页
    # authentication_classes = (JSONWebTokenAuthentication, authentication.SessionAuthentication)
